#!/usr/bin/env python

import sys

import tables
import histogram

if len(sys.argv) != 2:
    sys.stderr.write("Usage: ptcolumn_hists.py file.h5\n")
    sys.stderr.flush()
    sys.exit(-1)

fp = tables.openFile(sys.argv[1], 'r')

ncol = len(fp.root.nt.colnames)
icol = 0

for col in fp.root.nt.colnames:
    icol += 1
    
    sys.stdout.write("{0}/{1} columns complete\r".format(icol, ncol))
    sys.stdout.flush()
    
    data = fp.root.nt.read(field=col)
    h = histogram.Histogram1D(col, 100, (min(data), max(data)), col, "", use_latex=False)
    h.fill(data)
    h.draw()

print 

